import React, { lazy, useState, Suspense } from "react";
import { Button, CircularProgress } from "@material-ui/core";
const SpineViewer = lazy(() => import("./SpineViewer"));
export function View() {
  const [load, setLoad] = useState(false);
  console.log(load);
  return (
    <>
      {load ? (
        <Suspense fallback={<CircularProgress color="secondary" />}>
          <SpineViewer></SpineViewer>
        </Suspense>
      ) : (
        <Button
          variant="contained"
          color="primary"
          onClick={() => {
            setLoad(true);
          }}
        >
          点击加载
        </Button>
      )}
    </>
  );
}
